package circle

import (
	"fmt"
	"reflect"
)

func TestFor() {

	sum := 0
	for i := 0; i < 100; i++ {
		sum = sum + i
	}
	fmt.Println(sum)

	for sum < 100 {
		sum = sum + 1
	}
	for false {
		fmt.Println("no limit circle")
	}
	//for each
	strings := [2]string{"bob", "jim"}
	for _, i := range strings {
		fmt.Println(i)
	}
	fmt.Println(reflect.TypeOf(strings))
	var i, j int
	for i = 2; i < 100; i++ {
		for j = 2; j < i/j; j++ {
			if i%j == 0 {
				break
			}
		}
		if j > i/j {
			fmt.Printf("%d 是素数\\n", i)
		}
	}
	//九九乘法表
	for m := 1; m < 10; m++ {
		for n := 1; n <= m; n++ {
			fmt.Printf("%dX%d=%d\t", n, m, n*m)
		}
		fmt.Println("")

	}
	//continue
	var a int = 10
	for a < 20 {
		if a == 15 {
			a++
			continue
		}
		fmt.Println(a)
		a++
	}
	//break

	for a < 40 {
		if a == 35 {
			a++
			break
		}
		fmt.Println(a)
		a++
	}
	//goto
LOOP2:
	fmt.Println("i am back")
	for a < 70 {
		if a == 55 {
			a = a + 1
			goto LOOP2
		}
		fmt.Println(a)
		a++
	}
}
